package ExceptionAndIO.Exception;

import org.testng.annotations.Test;

import java.util.Scanner;

public class ExceptionDemo {

    @Test
    public void test1(){
        try{
            int a=1/0;
        }catch (Exception e){
            System.out.println("出错了");
        }
    }
    public static void main(String[] arg) throws MySquareRootException {
        Scanner sc=new Scanner(System.in);

        while(true){
            double db=sc.nextDouble();
            if(db<0){
                throw new MySquareRootException("输入错误，不能对负数求平方根");
            }else{
                System.out.println("平方根为："+Math.sqrt(db));
            }
        }
    }

}
